const express = require('express');
const cors = require('cors');
const bodyParser = require('body-parser');
// 引入路由
const studentRouter = require('./router/student');

// 引入数据库
const db = require('./db/index');
const app = express();
// 静态文件暴露
app.use(express.static('public'));
// 解决跨域
app.use(cors());
// 将post请求体放到req.body上
app.use(bodyParser.urlencoded({extended:true}));
// 应用路由
app.use(studentRouter);

app.listen(8000,err=>{
    if(!err){
        console.log('服务器启动成功');
    }else{
        console.log(err);
    }
})